package entityJPA;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;


/**
 * The persistent class for the positiondescription database table.
 * 
 */
@Entity
@Table(name="positiondescription")
@NamedQuery(name="Positiondescription.findAll", query="SELECT p FROM Positiondescription p")
public class Positiondescription implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(unique=true, nullable=false)
	private int idPositionDescription;

	@Column(length=45)
	private String project;

	@Column(nullable=false, length=45)
	private String requirements;

	@Column(nullable=false, length=45)
	private String responsabilities;

	//bi-directional many-to-one association to Position
	@OneToMany(mappedBy="positiondescription")
	private List<Position> positions;

	//uni-directional many-to-one association to Department
	@ManyToOne
	@JoinColumn(name="idDepartment", nullable=false)
	private Department department;

	public Positiondescription() {
	}

	public int getIdPositionDescription() {
		return this.idPositionDescription;
	}

	public void setIdPositionDescription(int idPositionDescription) {
		this.idPositionDescription = idPositionDescription;
	}

	public String getProject() {
		return this.project;
	}

	public void setProject(String project) {
		this.project = project;
	}

	public String getRequirements() {
		return this.requirements;
	}

	public void setRequirements(String requirements) {
		this.requirements = requirements;
	}

	public String getResponsabilities() {
		return this.responsabilities;
	}

	public void setResponsabilities(String responsabilities) {
		this.responsabilities = responsabilities;
	}

	public List<Position> getPositions() {
		return this.positions;
	}

	public void setPositions(List<Position> positions) {
		this.positions = positions;
	}

	public Position addPosition(Position position) {
		getPositions().add(position);
		position.setPositiondescription(this);

		return position;
	}

	public Position removePosition(Position position) {
		getPositions().remove(position);
		position.setPositiondescription(null);

		return position;
	}

	public Department getDepartment() {
		return this.department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((department == null) ? 0 : department.hashCode());
		result = prime * result + ((project == null) ? 0 : project.hashCode());
		result = prime * result
				+ ((requirements == null) ? 0 : requirements.hashCode());
		result = prime
				* result
				+ ((responsabilities == null) ? 0 : responsabilities.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Positiondescription other = (Positiondescription) obj;
		if (department == null) {
			if (other.department != null)
				return false;
		} else if (!department.equals(other.department))
			return false;
		if (project == null) {
			if (other.project != null)
				return false;
		} else if (!project.equals(other.project))
			return false;
		if (requirements == null) {
			if (other.requirements != null)
				return false;
		} else if (!requirements.equals(other.requirements))
			return false;
		if (responsabilities == null) {
			if (other.responsabilities != null)
				return false;
		} else if (!responsabilities.equals(other.responsabilities))
			return false;
		return true;
	}

	
	public String toString(){
		return this.idPositionDescription+" "+this.project+" "+this.requirements;
	}
	

}